<template>
  <div class="mod-user">
    <el-card class="box-card" style="width:80%;margin:0 auto;">
      <el-form
        :model="dataForm"
        :rules="rules"
        ref="dataForm"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="商品分类" prop="productType">
          <el-select v-model="dataForm.productType">
            <el-option
              v-for="item in transferTypes"
              :label="item.typeTitle"
              :key="item.productType"
              :value="item.productType"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="商品名称" prop="productName">
          <el-input v-model="dataForm.productName" />
        </el-form-item>
        <el-form-item label="副标题" prop="shortName">
          <el-input type="password" v-model="dataForm.shortName" />
        </el-form-item>
        <el-form-item label="商品货号" prop="productSn">
          <el-input v-model="dataForm.productSn" />
        </el-form-item>
        <el-form-item label="商品售价" prop="realName">
          <el-input v-model="dataForm.realName" />
        </el-form-item>
        <el-form-item label="计量单位" prop="realName">
          <el-input v-model="dataForm.realName"></el-input>
        </el-form-item>
        <el-switch v-model="value1"  inactive-text="商品上架"></el-switch>
      </el-form>
    </el-card>
  </div>
</template>

<script>
export default {
  data () {
    return {
      checkList: ['选中且禁用', '复选框 A'],
      value1: true,
      value2: true,
      transferTypes: [
        { type: 1, typeTitle: '芒果' },
        { type: 2, typeTitle: '种子' }
      ],
      dataForm: {
        productType: 1,
        productName: '',
        shortName: '',
        productSn: ''
      },
      rules: {
        type: [{ required: true, message: '请选择转账类型', trigger: 'blur' }],
        memberName: [
          { required: true, message: '请输入收款用户名', trigger: 'blur' }
        ],
        num: [{ required: true, message: '转出数额不能为空', trigger: 'blur' }],
        password: [
          { required: true, message: '请输入您的二级密码', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    transfer () {
      this.$refs['dataForm'].validate(valid => {
        if (valid) {
          this.$http({
            url: this.$http.adornUrl('/product/save'),
            method: 'post',
            data: this.$http.adornData({
              productType: this.dataForm.productType,
              productName: this.dataForm.productName,
              shortName: this.dataForm.shortName,
              productSn: this.dataForm.productSn
            })
          }).then(({ data }) => {
            if (data && data.status === 200) {
              this.$message.success(data.message)
            } else {
              this.$message.error(data.message)
            }
          })
        }
      })
    }
  }
}
</script>
<style >
.el-card__body {
  width: 100%;
}
</style>
